package com.khotyn.heresy.ibatis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.khotyn.heresy.bean.PictureAlbum;
import com.khotyn.heresy.dao.PictureAlbumDAO;

/**
 * PictureAlbum DAO iBATIS实现
 * @author 黄挺
 */
public class PictureAlbumDAOIbatisImpl extends SqlMapClientDaoSupport implements PictureAlbumDAO{

	public Integer insertPictureAlbum(PictureAlbum pictureAlbum) {
		return (Integer) this.getSqlMapClientTemplate().insert("insertPictureAlbum", pictureAlbum);
	}
	
	public int deletePictureAlbumByID(PictureAlbum pictureAlbum){
		return this.getSqlMapClientTemplate().delete("deletePictureAlbumByID", pictureAlbum.getAlbumID());
	}

	public int deletePictureAlbumByPK(PictureAlbum pictureAlbum) {
		return this.getSqlMapClientTemplate().delete("deletePictureAlbumByPK", pictureAlbum );
	}

	public PictureAlbum selectPictureAlbumByPK(PictureAlbum pictureAlbum) {
		return (PictureAlbum) this.getSqlMapClientTemplate().queryForObject("selectPictureAlbumByPK", pictureAlbum);
	}

	@SuppressWarnings("unchecked")
	public List<PictureAlbum> selectPictureAlubmByAlbumID(Integer albumID) {
		return this.getSqlMapClientTemplate().queryForList("selectPictureAlubmByAlbumID", albumID);
	}

	public int deletePicAlbumByPicId(String pictureID) {
		return this.getSqlMapClientTemplate().delete("deletePicAlbumByPicId", pictureID);
	}

	@SuppressWarnings("unchecked")
	public List<PictureAlbum> selectPagedPictureAlbum(Integer albumID,
			Integer minRow, Integer maxRow) {
		Map map = new HashMap();
		map.put("albumID", albumID);
		map.put("minRow", minRow);
		map.put("maxRow", maxRow);
		
		return this.getSqlMapClientTemplate().queryForList("selectPagedPictureAlbum", map);
	}

	public Integer selectPicCountByAlbumID(Integer albumID) {
		return (Integer) this.getSqlMapClientTemplate().queryForObject("selectPicCountByAlbumID", albumID);
	}

	@SuppressWarnings("unchecked")
	public List<Integer> selectAlbumIdByPictureId(String pictureID) {
		return this.getSqlMapClientTemplate().queryForList("selectAlbumIdByPictureId", pictureID);
	}	
}
